package com.example.primarycalculator2;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.ShapeBadgeItem;
import com.ashokvarma.bottomnavigation.TextBadgeItem;

import java.util.List;


import org.litepal.LitePal;
import org.litepal.crud.LitePalSupport;


public class AnswerAdapter extends ArrayAdapter<Problem> {
    private int resourceId;

    public AnswerAdapter(@NonNull Context context, int resource, @NonNull List<Problem> objects) {
        super(context, resource, objects);
        this.resourceId=resource;
    }


    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Problem problem=getItem(position);
        View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        TextView problemContent=view.findViewById(R.id.problem);
        TextView problemAnswer=view.findViewById(R.id.answer);
        TextView problemRealAnswer=view.findViewById(R.id.real_answer);
        ImageView problemR=view.findViewById(R.id.pic);


        problemContent.setText(problem.getContent());
        problemAnswer.setText(problem.getAnswer());
        problemRealAnswer.setText(problem.getRealAnswer());
        problemR.setImageResource(problem.getPicId());
        return view;

    }






}
